<template>
	<div>
		<div class="info">
			{{error}}
		</div>
		<movie-poster v-for="(item,index) in movies" :url="getUrl(item.kw)" :poster="item.poster" :site="getSit(index+1)" :title="item.kw">
		
		</movie-poster>

	</div>
</template>

<script>
	
	import {
		search
	} from "../network/home.js"
	
	import moviePoster from "../components/moviePoster.vue"
	export default {
		name:'poster',
		data(){
			return {
				kw:'',
				movies:[],
				error:''
			}
		},
		components:{
			moviePoster
		},
		beforeCreate() {
			this.kw = this.$route.query.kw;
			search(this.kw)
			.then(res=>{
				this.movies = res.data;
				if(this.movies.length<=0)
				{
					this.error = "对不起！ 该影片 可能很稀少  没有检索到！"
				}
				})
			.catch(err=>{
				console.log(err);
			  this.error = "数据请求失败！请重新刷新一页"
				
			})
		},
		methods:{
			getUrl(kw,index){
				return "/play?kw="+kw/* +"&index="+index */
			},
			getSit(index){
				return "站点"+index;
			}
			
		},
		computed:{
		
		}
		
		
		
	}
</script>

<style>
</style>
